<template>
	<view class="address">
		<scroll-view class="address_list" scroll-y>
			<view>
				<uni-list v-for="(s,i) in data" :key="i">
					<uni-list-item @click="setAddress(s.id)" :clickable="true">
						<template v-slot:header>
							<uni-icons :type="index===s.id?'checkmarkempty': 'circle'" size="26" color="#8c8c8c"></uni-icons>
						</template>
						<template v-slot:body>
							<view class="list" >
								<view class="user">
									<uni-tag text="默认" type="error"  v-if="s.pid==1" ></uni-tag>
									<text>姓名:{{s.name}}</text>
									<text>电话:{{s.tel}}</text>
								</view>
								<view class="address">
									<text>收货地址:{{`${s.province}${s.diqutel}${s.county}${s.address}`}}</text>
								</view>
					
							</view>
						</template>
					<!-- 	<template v-slot:footer>
					<!-- 		<uni-icons type="compose" size="26" color="#8c8c8c" @click="setaddress"></uni-icons> -->
						<!-- </template> --> -->
					</uni-list-item>
				</uni-list>
			</view>
			<!-- <addressList :item="data"></addressList> -->
		</scroll-view>
		<view class="bottom">
			<button @click="goPaysuc">确认</button>
			<!-- <button @click="gowhere('/pages/AddAddress/AddAddress')">新增地址</button> -->
		</view>
	</view>
</template>

<script>
	import {shouhuocha} from '@/service/index.js'
	export default {
		
		data() {
			return {
             data:'',
			 index:''
			}
		},
	 async	onLoad() {
			let res=await shouhuocha(this.$uid)
			this.data=res.result
			console.log(this.data)
		},
		
		
		methods: {
			setAddress(e) {
				console.log(e)
			    this.index=e
				uni.setStorageSync('id',this.index);
				
			
			},
			setaddress(){
					uni.navigateTo({
						url:'/pages/AddAddress/AddAddress'
					})
			},
goPaysuc(){
	uni.navigateBack({
		url:'/pages/pay/pay',
			
	})

},
gowhere(url){
	uni.navigateTo({
		url:url
	})
}
		}
	}
</script>

<style lang="scss">
	page{
		height: 100%;
	}
	.address {
		height: 100%;
		position: relative;

		.address_list {
			height: 75%;
			overflow: hidden;
			.list {
				width: 70%;
				margin: 0 20px;
			
				.user {
					text {
						font-size: 14px;
					}
			
					:first-child {
						display: inline-block;
						margin: 0 3px 0 0;
					}
				}
			
				.address {
					font-size: 12px;
					width: 100%;
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
					color: #8b8b8b;
				}
			}
		}

		.bottom {
			background-color:transparent;
			height: 25%;
			width: 100%;
			position: fixed;
			bottom: 0;
			:first-child {
				margin: 20px 5px;
				border-radius: 50px;
				border: 1px solid rgb(159, 156, 230);
				background-color: transparent;
				color: rgb(159, 156, 230);
				font-size: 14px;
			}

			:last-child {
				margin: 20px 5px;
				border-radius: 50px;
				background-color: rgb(159, 156, 230);
				color: white;
				font-size: 14px;
			}
		}
	}
</style>
